package com.zxy.config;

import com.zxy.filter.TraceIdFilter;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class OpenFeignRequestInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate template) {
        String traceId = MDC.get(TraceIdFilter.TRACEID);
        template.header(TraceIdFilter.TRACEID,traceId);
        log.debug("我从mdc中拿到了traceId={},带个下游分服务了",traceId);
    }
}
